package com.liberty.dasheen.admin.sys.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.liberty.dasheen.admin.sys.service.MenuService;
import com.liberty.dasheen.entity.SysMenu;
import com.liberty.dasheen.mapper.SysMenuMapper;

@Service
public class MenuServiceImpl implements MenuService {
	
	@Autowired
	private SysMenuMapper menuMapper;

	@Override
	public List<SysMenu> listMenuByPId(String pid) {
		List<SysMenu> parent = menuMapper.listMenuByPId(pid);
		for (SysMenu sysMenu : parent) {
			List<SysMenu> children = new ArrayList<>();
			children = menuMapper.listMenuByPId(sysMenu.getId());
			sysMenu.setChildren(children);
		}
		return parent;
	}
	
}
